package com.tedu;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author CCFu
 * @version 1.0
 * @date 2021/11/18 18:30
 */
public class TestMap {
    public static void main(String[] args) {
        System.out.println("请输入要统计的字符串：");
        String s = new Scanner(System.in).nextLine();
        Map<Character,Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char key = s.charAt(i);
            Integer value = map.get(key);
            if (value == null){
                map.put(key,1);
            }else{
                map.put(key,value+1);
            }
        }
        System.out.println(map);

    }
}

